package com.cskaoyan.controller.promote;

import com.cskaoyan.model.bo.promote.WxFeedbackBo;
import com.cskaoyan.model.vo.BaseRespVo;
import com.cskaoyan.service.promote.WxFeedbackService;
import com.cskaoyan.utils.RegularUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * 意见反馈模块
 * @author：23117
 * @date: 2021/12/4
 */
@RestController
@RequestMapping("wx/feedback")
public class WxFeedbackController {
    @Autowired
    WxFeedbackService wxFeedbackService;

    @RequestMapping("submit")
    public BaseRespVo submit(@RequestBody WxFeedbackBo wxFeedbackBo, HttpSession httpSession){
        //处理请求参数
        Integer userid = (Integer) httpSession.getAttribute("uid");
            //手机号验证
        String mobile = wxFeedbackBo.getMobile();
        boolean mobile1 = RegularUtil.isMobile(mobile);
        if (mobile1){

        int status = wxFeedbackService.submit(wxFeedbackBo,userid);

        if (status==1) return BaseRespVo.ok();
        return null;
        }

        return BaseRespVo.manual(401,"手机号错误",null);
    }

}
